
import javax.swing.*;
import java.util.ArrayList;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Scores 
{

	ArrayList tempArrayList;	// holds the scores and names until they can be split
	ArrayList scores;
	ArrayList names;
	String filename;
	
	public Scores()
	{
		tempArrayList = new ArrayList();
		scores = new ArrayList();
		names = new ArrayList();
		this.filename = "Scores.txt";
		createGUI();
	}
	
	/**
	 * Creates the Scores screen graphics user
	 * interface that the user will see
	 */
	public static void createGUI()
	{
		JFrame scores = new JFrame();
	}
	
	/**
	 * displays the scores from previous games
	 */
	public void displayScores()
	{
		
	}
	
	/**
	 * adds score that player just recieved into
	 * the list of previous scores.
	 */
	public void addNewScore()
	{
		// compare new score versus old score.
		// if new score is bigger than an old one then replace
	}
	
	/**
	 * writes the scores and names into a file
	 * that will be its storage
	 * @return
	 */
	private boolean writeFile()
	{
		boolean error = false;

		try
		{
			File outFile = new File(filename);
			FileOutputStream output = new FileOutputStream(outFile);
			
			// do something here
		}
		catch(NullPointerException e)
		{
			error = true;
		}
		catch(FileNotFoundException e)
		{
			error = true;
		}
		catch(SecurityException e)
		{
			error = true;
		}
		
		return error;
	}
	
	/**
	 * reads the scores and names from a file
	 * that holds them while the game is not
	 * being played.
	 * @return
	 */
	private boolean readFile(String filename)
	{
		boolean error = false;
		String temp;
		
		try
		{
			FileReader infile = new FileReader(filename);
			BufferedReader buff = new BufferedReader(infile);
			
			temp = buff.readLine();
			while(temp != null)
			{
				tempArrayList.add(temp);
				temp = buff.readLine();
			}
		}
		catch(FileNotFoundException e)
		{
			error = true;
		}
		catch(IOException e)
		{
			error = true;
		}
		
		return error;
	}
	
	private boolean writeFile(String fileName)
	{
		boolean error = false;
		
		return error;
	}
	
	
	/**
	 *  
	 */
	private boolean updateScores()
	{
		boolean error = false;
		
		
		
		return error;
	}
	
}
